package com.huadao.cart_ccs.experiment.sample;

import com.huadao.cart_ccs.common.ExperimentStageManager;
import com.huadao.cart_ccs.common.ProjectManager;
import com.huadao.cart_ccs.greendao.GreenDaoManager;
import com.huadao.cart_ccs.greendao.entity.Sample;
import com.huadao.cart_ccs.greendao.gen.SampleDao;

import java.util.List;

public class SamplePresenter extends SampleContract.SamplePresenter {

    private SampleDao sampleDao;
    private long projectId;
    private long stageId;

    public SamplePresenter(SampleContract.ISampleView baseView) {
        attachView(baseView);
        sampleDao= GreenDaoManager.getInstance().getNoCacheSession().getSampleDao();
        projectId=ProjectManager.getInstance().getProjectId();
        stageId=ExperimentStageManager.getInstance().getStageId();
    }

    //只获取当天的记录
    @Override
    void getHistorySampleList() {
        List<Sample> sampleList=sampleDao.queryBuilder().where(SampleDao.Properties.ProjectId.eq(projectId),SampleDao.Properties.StageId.eq(stageId)).list();
        baseView.onGetHistorySampleList(sampleList);
    }
}
